#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int n, x;
    scanf("%d %d", &n, &x);
    int i;
    int count = 0;
    for (i = 1; i <= n; i++)
    {
        int m = i;
        while (m)
        {
            if (m % 10 == x)
                count++;
            m /= 10;
        }
    }
    printf("%d\n", count);
}
